package com.room.search.web.rest;

import com.room.search.core.page.TableDataInfo;
import com.room.search.service.RoomSearchGoodService;
import com.room.search.service.dto.SearchCommunityDataDTO;
import com.room.search.service.dto.SearchDataDTO;
import com.room.search.service.dto.TypeAndLocationDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

/**
 * REST controller for managing {@link com.room.search.domain.RoomSearchGood}.
 */
@RestController
@RequestMapping("/api/room")
public class RoomSearchGoodResource {

    private final Logger log = LoggerFactory.getLogger(RoomSearchGoodResource.class);

    private final RoomSearchGoodService searchGoodService;

    public RoomSearchGoodResource(RoomSearchGoodService searchGoodService) {
        this.searchGoodService = searchGoodService;
    }

    @PostMapping("/search")
    public TableDataInfo search(@RequestBody SearchDataDTO dto) {
        log.info("searchData：{}", dto);
        return searchGoodService.search(dto);
    }

    @GetMapping("/search_index")
    public TableDataInfo searchIndex(TypeAndLocationDTO dto) {
        return searchGoodService.searchIndex(dto);
    }


    @GetMapping("/search_community_index")
    public TableDataInfo searchCommunityIndex(TypeAndLocationDTO dto) {
        return searchGoodService.searchCommunityIndex(dto);
    }

    @PostMapping("/search_community")
    public TableDataInfo searchCommunity(@RequestBody SearchCommunityDataDTO dto) {
        return searchGoodService.searchCommunity(dto);
    }
}
